/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vhdl;


import java.awt.AWTException;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.*;
import java.io.*;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.DropMode;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
import java.awt.Robot;
import java.util.Vector;
import org.tmatesoft.svn.core.*;
import org.tmatesoft.svn.core.javahl.*;
import org.tmatesoft.svn.cli.*;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.io.ISVNReporter;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.*;
import org.tmatesoft.svn.util.*;
//import 


/**
 *
 * @author qubits
 */
public class VHDLview extends javax.swing.JFrame {

    /**
     * Creates new form VHDLview
     */
    
    public DefaultTableModel model = new DefaultTableModel();
    public DefaultTableModel tbModel = new DefaultTableModel();
    public DefaultTableModel envModel = new DefaultTableModel();
    private String[] dsnTypeStr = {".vhd",".v"};
    public VHDLview() throws TooManyListenersException {
        initComponents();
//        jTable1.setSelectionModel(ListSelectionModel.SINGLE_SELECTION);
        jTable1.setDropMode(DropMode.INSERT);
        model= (DefaultTableModel) jTable1.getModel();
        tbModel = (DefaultTableModel) tbTable.getModel();
        envModel = (DefaultTableModel) envTable.getModel();
        logText.setEditable(false);
        ProcessBuilder pb = new ProcessBuilder("pwd");
        Process p;
        try {
            p = pb.start();
            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String line = reader.readLine();
            jLabel1.setText("Base Dir: "+line);
        } catch (IOException ex) {
            Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        DropTarget dt = new DropTarget();
        dt.setComponent(jTable1);
        dt.addDropTargetListener(new DropTargetListener() {

            public void dragEnter(DropTargetDragEvent dtde) {
                System.out.println("dragEnter");
            }

            public void dragOver(DropTargetDragEvent dtde) {
                System.out.println("dragOver");
            }

            public void dropActionChanged(DropTargetDragEvent dtde) {
                System.out.println("dropActionChanged");
            }

            public void dragExit(DropTargetEvent dte) {
                System.out.println("dragExit");
            }

            public void drop(DropTargetDropEvent dtde) {
                try {
                    Transferable tr = dtde.getTransferable();
                    
                    DataFlavor[] flavors = tr.getTransferDataFlavors();
                    for (int i = 0; i < flavors.length; i++) {
                        System.out.println("Possible flavors: " + flavors[i].getMimeType() + " xx:" +flavors[i].isFlavorJavaFileListType());
                        if (flavors[i].isFlavorJavaFileListType()||true) {
                            System.out.println("1");
                            dtde.acceptDrop(DnDConstants.ACTION_COPY);
                            //jList1.setText("Successful file list drop.\n\n");
                            System.out.println("2");
                            java.util.List list = (java.util.List) tr.getTransferData(new DataFlavor("application/x-java-file-list;class=java.util.List"));
                            System.out.println("3");
                            for (int j = 0; j < list.size(); j++) {
                                System.out.println("4");
                                model.setValueAt(list.get(j), 0, i);
                                jTable1.setModel(model);
                                //model.addElement(list.get(j) + "\n");
                                //jList1.setModel(model);
                            }
                            dtde.dropComplete(true);
                            return;
                        }
                    }
                    System.out.println("Drop failed: " + dtde);
                    dtde.rejectDrop();
                } catch (Exception e) {
                    e.printStackTrace();
                    dtde.rejectDrop();
                }
            }
        });
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        designPane = new javax.swing.JTabbedPane();
        jPanel5 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        usernameField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        passwordField = new javax.swing.JPasswordField();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        auto_populate_button = new javax.swing.JButton();
        dsnCompileButton = new javax.swing.JButton();
        updateRevButton = new javax.swing.JButton();
        head_rev_label = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tbTable = new javax.swing.JTable();
        autoFillTB = new javax.swing.JButton();
        dupButton = new javax.swing.JButton();
        runButton = new javax.swing.JButton();
        runAllButton = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        envTable = new javax.swing.JTable();
        autoEnv = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        cdcButton = new javax.swing.JButton();
        spyglassButton = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        logText = new javax.swing.JTextArea();
        logSearchText = new javax.swing.JTextField();
        searchButton = new javax.swing.JButton();
        jScrollPane5 = new javax.swing.JScrollPane();
        logFileList = new javax.swing.JList();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Base Dir:");

        jLabel2.setText("SVN URL: ");

        jLabel3.setText("SVN user:");

        jLabel4.setText("SVN pass:");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel5Layout.createSequentialGroup()
                            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel3)
                                .addComponent(jLabel2))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 406, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(usernameField, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel5Layout.createSequentialGroup()
                            .addComponent(jLabel4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(usernameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(208, Short.MAX_VALUE))
        );

        designPane.addTab("Configuration", jPanel5);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Files", "Compile", "coverage", "com", "options", "SVN Rev"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.Boolean.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jTable1.setDragEnabled(true);
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(200);

        auto_populate_button.setText("Auto");
        auto_populate_button.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                auto_populate_buttonMouseClicked(evt);
            }
        });
        auto_populate_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                auto_populate_buttonActionPerformed(evt);
            }
        });

        dsnCompileButton.setText("Compile");
        dsnCompileButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                dsnCompileButtonMouseClicked(evt);
            }
        });

        updateRevButton.setText("Update Rev");
        updateRevButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                updateRevButtonMouseClicked(evt);
            }
        });

        head_rev_label.setText("Head Rev: ");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(head_rev_label)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(updateRevButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dsnCompileButton)
                        .addGap(18, 18, 18)
                        .addComponent(auto_populate_button))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 484, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(auto_populate_button)
                        .addComponent(dsnCompileButton)
                        .addComponent(updateRevButton))
                    .addComponent(head_rev_label, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );

        designPane.addTab("Design", jPanel1);

        tbTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Testbench", "Defines", "Compile", "GUI", "com", "SVN Rev"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Boolean.class, java.lang.Boolean.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        tbTable.setDragEnabled(true);
        tbTable.setDropMode(javax.swing.DropMode.ON);
        jScrollPane2.setViewportView(tbTable);
        tbTable.getColumnModel().getColumn(0).setPreferredWidth(200);

        autoFillTB.setText("Auto");
        autoFillTB.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                autoFillTBMouseClicked(evt);
            }
        });
        autoFillTB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                autoFillTBActionPerformed(evt);
            }
        });

        dupButton.setText("Add instance");
        dupButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                dupButtonMouseClicked(evt);
            }
        });

        runButton.setText("Run");
        runButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                runButtonMouseClicked(evt);
            }
        });

        runAllButton.setText("Run All");
        runAllButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                runAllButtonMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 484, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(0, 224, Short.MAX_VALUE)
                        .addComponent(runAllButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(runButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dupButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(autoFillTB)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(dupButton)
                    .addComponent(autoFillTB)
                    .addComponent(runButton)
                    .addComponent(runAllButton)))
        );

        designPane.addTab("Testbench", jPanel2);

        envTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Environment", "Options", "Compile", "com", "SVN Rev"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Boolean.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        envTable.setColumnSelectionAllowed(true);
        jScrollPane3.setViewportView(envTable);
        envTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        envTable.getColumnModel().getColumn(0).setPreferredWidth(200);

        autoEnv.setText("Auto");
        autoEnv.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                autoEnvMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 484, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(autoEnv)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(autoEnv)
                .addContainerGap())
        );

        designPane.addTab("Environment", jPanel3);

        cdcButton.setText("0-in cdc");
        cdcButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                cdcButtonMouseClicked(evt);
            }
        });

        spyglassButton.setText("spyglass");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cdcButton)
                    .addComponent(spyglassButton))
                .addContainerGap(426, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cdcButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(spyglassButton)
                .addContainerGap(260, Short.MAX_VALUE))
        );

        designPane.addTab("0-in/Spyglass", jPanel4);

        logText.setColumns(20);
        logText.setRows(5);
        jScrollPane4.setViewportView(logText);

        logSearchText.setText("Search term/grep expression");

        searchButton.setText("Search");

        logFileList.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                logFileListMouseClicked(evt);
            }
        });
        jScrollPane5.setViewportView(logFileList);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(logSearchText)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(searchButton))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane4)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(logSearchText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(searchButton))
                .addContainerGap())
        );

        designPane.addTab("tab6", jPanel6);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(designPane)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(designPane, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void auto_populate_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_auto_populate_buttonActionPerformed
        // TODO add your handling code here:

   }//GEN-LAST:event_auto_populate_buttonActionPerformed
    private String[] filelist(File dir){
        FileFilter f= new FileFilter() {

                @Override
                public boolean accept(File pathname) {
                    //throw new UnsupportedOperationException("Not supported yet.");
                    return pathname.isFile();
                }
            };
        FileFilter fdir= new FileFilter() {

                @Override
                public boolean accept(File pathname) {
                    //throw new UnsupportedOperationException("Not supported yet.");
                    return pathname.isDirectory();
                }
            };
        FilenameFilter fn = new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                //throw new UnsupportedOperationException("Not supported yet.");
                boolean dsnBool = false;
                for(int i=0;i<dsnTypeStr.length;i++){
                    if(name.endsWith(dsnTypeStr[i]))
                        return true;
                }
                return false;
            }
        };
        String[] flist= dir.list(fn);
        for(int i=0;i<flist.length;i++){
            flist[i]=dir.toString()+"/"+flist[i];
        }
        File[] dirList = dir.listFiles(fdir);
        if(dirList !=null){
            for(int i=0;i<dirList.length;i++){
                System.out.println("DIR: "+dirList[i].toString());
                String[] tempList=filelist(new File(dirList[i].toString()));
                if(tempList!=null){
                    String[] cStr=new String[flist.length+tempList.length];
                    for (int j=0;j<cStr.length;j++){
                        if(j<flist.length)
                            cStr[j]=flist[j];
                        if(j>=flist.length)
                            cStr[j]=/*dirList[i].toString()+"/"+*/tempList[j-flist.length];
                    }
                    flist=cStr;
                }                
            }
        }
        return flist;
    }
    private void auto_populate_buttonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_auto_populate_buttonMouseClicked
        try {
            // TODO add your handling code here:
            File dir = new File("src/dsn");
            String[] x=filelist(dir);
            for(int i=0;i<x.length;i++){
                System.out.println(x[i]+": filelist");
            }
            System.out.println("done....");
            FileFilter f= new FileFilter() {

                @Override
                public boolean accept(File pathname) {
                    //throw new UnsupportedOperationException("Not supported yet.");
                    return pathname.isFile();
                }
            };
            
            File[] children = dir.listFiles(f);
            for(int i =0; i<children.length; i++){
                
                System.out.println(children[i].toString()+ ":  dir-list");
            }
            children = dir.listFiles(new FileFilter(){
                @Override
                public boolean accept(File pathname){
                    return pathname.isDirectory();
                } 
            });
            for(int i =0; i<children.length; i++){
                
                System.out.println(children[i].toString()+ ":  dir");
            }
            ProcessBuilder pb = new ProcessBuilder("ls","src/dsn");
            //pb.command
            Process p = pb.start();
            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
            String line = reader.readLine();
            //writer.write("ls");
            //writer.newLine();
            //writer.flush();
            try {
                Thread.sleep(500);
            } catch (InterruptedException ex) {
                Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
            }
            int count_limit = model.getRowCount();
            for (int counter = 0; counter < count_limit - 1; counter++) {
                //System.out.println("counter: " + counter + " row count: " + model.getRowCount());
                //model.removeRow(model.getRowCount() - 1);
            }
            System.out.println(line);
            //while (line != null) {
            for(int i=0;i<x.length;i++){
                line=x[i];
                //System.out.println("w1");
                System.out.println(line);
                //model.setValueAt(line, i, 0);
                Object[] dataRow = {line, true, "", "","",0};
                boolean found=false;
                for(int counter = 0;counter<model.getRowCount();counter++)
                    if(model.getValueAt(counter, 0).toString().compareTo(line)==0)
                        found=true;
                if(!found){
                    model.addRow(dataRow);
                    jTable1.setModel(model);
                }
                
                if (reader.ready()) {
                    //System.out.println("ready");
                    line = reader.readLine();
                } else {
                    line = null;
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
        }
        //pb
    }//GEN-LAST:event_auto_populate_buttonMouseClicked

    private void autoFillTBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_autoFillTBActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_autoFillTBActionPerformed

    private void autoFillTBMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_autoFillTBMouseClicked
        // TODO add your handling code here:
        try {
            // TODO add your handling code here:
            File dir = new File("src/tb");
            String[] x=filelist(dir);
            ProcessBuilder pb = new ProcessBuilder("ls", "src/tb");
            Process p = pb.start();
            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
            String line = reader.readLine();
            //writer.write("ls");
            //writer.newLine();
            //writer.flush();
            try {
                Thread.sleep(500);
            } catch (InterruptedException ex) {
                Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
            }
            int count_limit = tbModel.getRowCount();
            for (int counter = 0; counter < count_limit - 1; counter++) {
                //System.out.println("counter: " + counter + " row count: " + model.getRowCount());
                //model.removeRow(model.getRowCount() - 1);
            }
            for(int i=0;i<x.length;i++){
                line=x[i];
                //System.out.println("w1");
                System.out.println(line);
                //tbModel.setValueAt(line, i, 0);
                Object[] dataRow = {line,"", true,false,"",0};
                boolean found=false;
                for(int counter = 0;counter<tbModel.getRowCount();counter++)
                    if(tbModel.getValueAt(counter, 0).toString().compareTo(line)==0)
                        found=true;
                if(!found){
                    tbModel.addRow(dataRow);
                    tbTable.setModel(tbModel);
                }
                if (reader.ready()) {
                    //System.out.println("ready");
                    line = reader.readLine();
                } else {
                    line = null;
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_autoFillTBMouseClicked

    private void autoEnvMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_autoEnvMouseClicked
        // TODO add your handling code here:
        try {
            // TODO add your handling code here:
            File dir = new File("src/env");
            String[] x=filelist(dir);
            ProcessBuilder pb = new ProcessBuilder("ls");
            Process p = pb.start();
            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
            String line = reader.readLine();
            //writer.write("ls");
            //writer.newLine();
            //writer.flush();
            try {
                Thread.sleep(500);
            } catch (InterruptedException ex) {
                Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
            }
            int count_limit = envModel.getRowCount();
            for (int counter = 0; counter < count_limit - 1; counter++) {
                //System.out.println("counter: " + counter + " row count: " + model.getRowCount());
                //model.removeRow(model.getRowCount() - 1);
            }
            for(int i=0;i<x.length;i++){
                line=x[i];
                //System.out.println("w1");
                System.out.println(line);
                //model.setValueAt(line, i, 0);
                Object[] dataRow = {line, "",true,"",""};
                boolean found=false;
                for(int counter = 0;counter<envModel.getRowCount();counter++)
                    if(envModel.getValueAt(counter, 0).toString().compareTo(line)==0)
                        found=true;
                if(!found){
                    envModel.addRow(dataRow);
                    envTable.setModel(envModel);
                }
                
                if (reader.ready()) {
                    //System.out.println("ready");
                    line = reader.readLine();
                } else {
                    line = null;
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_autoEnvMouseClicked

    private void exec_file(String[] commands){
        ProcessBuilder pbx = new ProcessBuilder("chmod","+x","tmp_exec");
        FileWriter fstream = null;
        try {
            fstream = new FileWriter("tmp_exec");
            BufferedWriter out = new BufferedWriter(fstream);
            for(int i=0;i<commands.length;i++)
                out.write(commands[i]+"\n");
            out.close();
        } catch (IOException ex) {
            Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                fstream.close();
            } catch (IOException ex) {
                Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        Process px;
        try {
            px = pbx.start();
            try {
                px.waitFor();
            } catch (InterruptedException ex) {
                Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (IOException ex) {
            Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        ProcessBuilder pb = new ProcessBuilder("ls");
        try {
            Process p = pb.start();
        } catch (IOException ex) {
            Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
    }
    private void dsnCompileButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_dsnCompileButtonMouseClicked
        // TODO add your handling code here:
        /*OutputStream out = null;  
        try {  
            Process proc = new ProcessBuilder("xterm").start();  
            out = proc.getOutputStream();  
            out.write("cd /home/qubits/Desktop/".getBytes());  
            out.flush();  
        } catch (IOException e1) {  
            // TODO Auto-generated catch block  
            e1.printStackTrace();  
        }  
        finally {  
            if (out != null) {  
                try {  
                    out.close();  
                } catch (IOException e) {  
                    // TODO Auto-generated catch block  
                    e.printStackTrace();  
                }                     
            }  
        }
        logText.append("text area\n");
        */
        int overhead=5;
        
        String[] comm= new String[model.getRowCount()+overhead];
        
        comm[0]="source startfile";
        comm[1]="cd $BASE_DIR/sim/libs";
        comm[2]="rm -Rf work";
        comm[3]="vlib work";
        comm[4]="cd $BASE_DIR";

        for(int i=0;i<model.getRowCount();i++){
            if(((Boolean)model.getValueAt(i, 1)).booleanValue()){
                comm[i+overhead]="vcom -cover "+model.getValueAt(i, 2).toString()+" "+model.getValueAt(i, 0).toString();
            }
        }
        exec_file(comm);
    }//GEN-LAST:event_dsnCompileButtonMouseClicked

    private void dupButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_dupButtonMouseClicked
        // TODO add your handling code here:
        int selectedIndex=tbTable.getSelectedRow();
        if(selectedIndex!=-1){
            Object[] dataRow = new Object[tbTable.getColumnCount()];
            for(int i=0; i<tbTable.getColumnCount();i++){
                dataRow[i]=tbModel.getValueAt(selectedIndex, i);
            }
            tbModel.addRow(dataRow);
            tbModel.moveRow(selectedIndex+1, tbModel.getRowCount()-2, selectedIndex+2);

        }
            
    }//GEN-LAST:event_dupButtonMouseClicked

    private void runButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_runButtonMouseClicked
        // TODO add your handling code here:
        for(int i=0;i<tbModel.getRowCount();i++){
            if(((Boolean)tbModel.getValueAt(i,tbModel.findColumn("Compile"))).booleanValue()){
                boolean guiOption=((Boolean)tbModel.getValueAt(i, tbModel.findColumn("Gui"))).booleanValue();
                String file=(String)tbModel.getValueAt(i, tbModel.findColumn("Testbench"));
                String[] command={"source startfile",""};
                ProcessBuilder pb=new ProcessBuilder();
                pb.command(command);
                try {
                    Process p= pb.start();
                } catch (IOException ex) {
                    Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }//GEN-LAST:event_runButtonMouseClicked

    private void runAllButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_runAllButtonMouseClicked
        // TODO add your handling code here:
        for(int i=0;i<tbModel.getRowCount();i++){
            //if(((Boolean)tbModel.getValueAt(i,tbModel.findColumn("Compile"))).booleanValue()){
            boolean guiOption=((Boolean)tbModel.getValueAt(i, tbModel.findColumn("Gui"))).booleanValue();
            String file=(String)tbModel.getValueAt(i, tbModel.findColumn("Testbench"));
            String[] command={"source startfile",""};
            ProcessBuilder pb=new ProcessBuilder();
            pb.command(command);
            try {
                Process p= pb.start();
            } catch (IOException ex) {
                Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
            }
            //}
        }
    }//GEN-LAST:event_runAllButtonMouseClicked

    private void logFileListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_logFileListMouseClicked
        // TODO add your handling code here:
        if (evt.getClickCount() == 2 && !evt.isConsumed()) {
            evt.consume();
            System.out.println("double-click");
            //logFileList.logFileList.getSelectedIndex();
            //handle double click.
        }
    }//GEN-LAST:event_logFileListMouseClicked

    private void cdcButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cdcButtonMouseClicked
        // TODO add your handling code here:
        String[] com={"source startfile","cd sim","make all"};
        exec_file(com);
    }//GEN-LAST:event_cdcButtonMouseClicked

    private void updateRevButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_updateRevButtonMouseClicked
        // TODO add your handling code here:
        updateRevx();
    }//GEN-LAST:event_updateRevButtonMouseClicked

    private void updateRevx(){

        ISVNOptions myOptions = SVNWCUtil.createDefaultOptions(true);

                
        
        SVNClientManager clientManager = SVNClientManager.newInstance();
        //clientManager.
        SVNStatusClient statusClient = clientManager.getStatusClient();
        SVNStatus status=null;
        String url=null;
        try {
            status=statusClient.doStatus(new File(""), false);
            SVNURL svn_url=status.getURL();
            url=svn_url.toString();
        } catch (SVNException ex) {
            Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        String temp="";
        jTextField1.setText(url);
        String name=usernameField.getText();
        char[] pass= passwordField.getPassword();
        String password="";
        for(int i=0;i<pass.length;i++)
            password+=pass[i];
        SVNRepository repository = null;
        try { 
            repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url));
            ISVNAuthenticationManager authManager = 
                        SVNWCUtil.createDefaultAuthenticationManager(name, password);
            clientManager.setAuthenticationManager(authManager);
            repository.setAuthenticationManager(authManager);
            
        } catch (SVNException e){

        }
        try {
            head_rev_label.setText("Head Rev: "+repository.getLatestRevision());
        } catch (SVNException ex) {
            Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        for(int i=0;i<model.getRowCount();i++){
            
            try {
                System.out.println("update rev x:");
                status =statusClient.doStatus(new File(model.getValueAt(i, 0).toString()), true);
                
            } catch (SVNException ex) {
                Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
            }
            finally{
                SVNStatusType type = status.getContentsStatus();
                if(type != SVNStatusType.STATUS_UNVERSIONED){
                    //statusClient.
                    SVNRevision revision = status.getRevision();
                    SVNRevision com_rev = status.getCommittedRevision();
                    //SVNRevision
                    //SVNStatusType =
                    SVNRevision remote_rev = status.getRemoteRevision();
                    
                    //SVNRevision remote_rev = status.getRemoteRevision();
                    temp="";
                    if(type == SVNStatusType.STATUS_MODIFIED)
                        temp+="M";
                    else if (type == SVNStatusType.STATUS_CONFLICTED)
                        temp+="C";
                    else if (type == SVNStatusType.STATUS_ADDED)
                        temp+="A";
                    else if (type == SVNStatusType.STATUS_DELETED)
                        temp+="D";
                    else if (type == SVNStatusType.MERGED)
                        temp+="G";
                    
                    temp+=" ";
                    System.out.println("updateRevx" +revision.getID());
                    try {
                        model.setValueAt(temp +com_rev.getNumber() + " / " + repository.getLatestRevision()/*+remote_rev.getNumber()*/, i, model.getColumnCount()-1);
                    } catch (SVNException ex) {
                        Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                else{
                    model.setValueAt("?", i ,model.getColumnCount()-1);
                }
            }
            
            
        }
        for(int i=0;i<tbModel.getRowCount();i++){
            try {
                System.out.println("update rev x:");
                status =statusClient.doStatus(new File(tbModel.getValueAt(i, 0).toString()), true);
                
            } catch (SVNException ex) {
                Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
            }
            finally{
                SVNStatusType type = status.getContentsStatus();
                if(type != SVNStatusType.STATUS_UNVERSIONED){
                    //statusClient.
                    SVNRevision revision = status.getRevision();
                    SVNRevision com_rev = status.getCommittedRevision();
                    //SVNRevision
                    //SVNStatusType =
                    SVNRevision remote_rev = status.getRemoteRevision();
                    
                    //SVNRevision remote_rev = status.getRemoteRevision();
                    temp="";
                    if(type == SVNStatusType.STATUS_MODIFIED)
                        temp+="M";
                    else if (type == SVNStatusType.STATUS_CONFLICTED)
                        temp+="C";
                    else if (type == SVNStatusType.STATUS_ADDED)
                        temp+="A";
                    else if (type == SVNStatusType.STATUS_DELETED)
                        temp+="D";
                    else if (type == SVNStatusType.MERGED)
                        temp+="G";
                    
                    temp+=" ";
                    System.out.println("updateRevx" +revision.getID());
                    try {
                        tbModel.setValueAt(temp +com_rev.getNumber() + " / " + repository.getLatestRevision()/*+remote_rev.getNumber()*/, i, tbModel.getColumnCount()-1);
                    } catch (SVNException ex) {
                        Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                else{
                    tbModel.setValueAt("?", i ,tbModel.getColumnCount()-1);
                }
            }
        }
        for(int i=0;i<envModel.getRowCount();i++){
            try {
                System.out.println("update rev x:");
                status =statusClient.doStatus(new File(envModel.getValueAt(i, 0).toString()), true);
                
            } catch (SVNException ex) {
                Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
            }
            finally{
                SVNStatusType type = status.getContentsStatus();
                if(type != SVNStatusType.STATUS_UNVERSIONED){
                    //statusClient.
                    SVNRevision revision = status.getRevision();
                    SVNRevision com_rev = status.getCommittedRevision();
                    //SVNRevision
                    //SVNStatusType =
                    SVNRevision remote_rev = status.getRemoteRevision();
                    
                    //SVNRevision remote_rev = status.getRemoteRevision();
                    temp="";
                    if(type == SVNStatusType.STATUS_MODIFIED)
                        temp+="M";
                    else if (type == SVNStatusType.STATUS_CONFLICTED)
                        temp+="C";
                    else if (type == SVNStatusType.STATUS_ADDED)
                        temp+="A";
                    else if (type == SVNStatusType.STATUS_DELETED)
                        temp+="D";
                    else if (type == SVNStatusType.MERGED)
                        temp+="G";
                    
                    temp+=" ";
                    System.out.println("updateRevx" +revision.getID());
                    try {
                        envModel.setValueAt(temp +com_rev.getNumber() + " / " + repository.getLatestRevision()/*+remote_rev.getNumber()*/, i, envModel.getColumnCount()-1);
                    } catch (SVNException ex) {
                        Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                else{
                    envModel.setValueAt("?", i ,envModel.getColumnCount()-1);
                }
            }
        }
    }
    
    private void updateRev(){
        updateRevx();
        for(int i =0;i<model.getRowCount();i++){
            
            try {
                //FileWriter f=new FileWriter("updateRev");
                //f.write("svn status -u " + model.getValueAt(i, 0).toString()+"\n");
                
                ProcessBuilder pb = new ProcessBuilder("svn","status","-u",model.getValueAt(i, 0).toString());
                //pb.
                Process p = pb.start();
                BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
                BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
                try {
                    p.waitFor();
                } catch (InterruptedException ex) {
                    Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
                }
                String processStr = reader.readLine();
                System.out.println(processStr);
                //writer.write("ls");
                //writer.newLine();
                int j=0;
                String temp="";
                
                while (processStr!= null) {
                    //System.out.println("w1");
                    System.out.println(processStr+"x");
                    //model.setValueAt(line, i, 0);
                    if(!processStr.startsWith("Status")){
                        //processStr.split(line);
                        int k=0;
                        while(processStr.charAt(k)==' '){
                            k++;
                            System.out.println(k+"char"+temp);
                        }
                        System.out.println(k);
                        temp+=processStr.charAt(k);
                        temp+=" ";
                        k++;
                        
                        while(processStr.charAt(k)==' '){
                            k++;
                            System.out.println(k+"rev"+temp);
                        }
                        temp+=processStr.charAt(k);
                        k++;
                        while(processStr.charAt(k)!=' '){
                            temp+=processStr.charAt(k);
                            System.out.println(k+"se"+temp);
                            k++;
                        }
                        System.out.println(k+"se"+temp);
                        temp+=" / ";
                        //return temp;
                        //model.setValueAt(temp, i, model.getColumnCount()-1);
                    }
                    if(processStr.startsWith("Status")){
                        int m=processStr.length()-1;
                        String temp2="";
                        while(processStr.charAt(m)!=' '){
                            temp2=processStr.charAt(m) +temp2;
                            m--;
                        }
                        temp=temp+temp2;
                    }
                    //temp=temp+temp2;
                    model.setValueAt(temp, i, model.getColumnCount()-1);

                    if (reader.ready()) {
                        //System.out.println("ready");
                        processStr = reader.readLine();
                    } else {
                        processStr = null;
                    }
                }

                p.destroy();
            } catch (IOException ex) {
                Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        
        
        
        for(int i =0;i<tbModel.getRowCount();i++){
            
            try {
                //FileWriter f=new FileWriter("updateRev");
                //f.write("svn status -u " + model.getValueAt(i, 0).toString()+"\n");
                
                ProcessBuilder pb = new ProcessBuilder("svn","status","-u",tbModel.getValueAt(i, 0).toString());
                //pb.
                Process p = pb.start();
                BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
                BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
                try {
                    p.waitFor();
                } catch (InterruptedException ex) {
                    Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
                }
                String processStr = reader.readLine();
                System.out.println(processStr);
                //writer.write("ls");
                //writer.newLine();
                int j=0;
                String temp="";
                
                while (processStr!= null) {
                    //System.out.println("w1");
                    System.out.println(processStr+"x");
                    //model.setValueAt(line, i, 0);
                    if(!processStr.startsWith("Status")){
                        //processStr.split(line);
                        int k=0;
                        while(processStr.charAt(k)==' '){
                            k++;
                            System.out.println(k+"char"+temp);
                        }
                        System.out.println(k);
                        temp+=processStr.charAt(k);
                        temp+=" ";
                        k++;
                        
                        while(processStr.charAt(k)==' '){
                            k++;
                            System.out.println(k+"rev"+temp);
                        }
                        temp+=processStr.charAt(k);
                        k++;
                        while(processStr.charAt(k)!=' '){
                            temp+=processStr.charAt(k);
                            System.out.println(k+"se"+temp);
                            k++;
                        }
                        System.out.println(k+"se"+temp);
                        temp+=" / ";
                        //return temp;
                        //model.setValueAt(temp, i, model.getColumnCount()-1);
                    }
                    if(processStr.startsWith("Status")){
                        int m=processStr.length()-1;
                        String temp2="";
                        while(processStr.charAt(m)!=' '){
                            temp2=processStr.charAt(m) +temp2;
                            m--;
                        }
                        temp=temp+temp2;
                    }
                    //temp=temp+temp2;
                    tbModel.setValueAt(temp, i, tbModel.getColumnCount()-1);

                    if (reader.ready()) {
                        //System.out.println("ready");
                        processStr = reader.readLine();
                    } else {
                        processStr = null;
                    }
                }

                p.destroy();
            } catch (IOException ex) {
                Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        
        
        for(int i =0;i<envModel.getRowCount();i++){
            
            try {
                //FileWriter f=new FileWriter("updateRev");
                //f.write("svn status -u " + model.getValueAt(i, 0).toString()+"\n");
                
                ProcessBuilder pb = new ProcessBuilder("svn","status","-u",envModel.getValueAt(i, 0).toString());
                //pb.
                Process p = pb.start();
                BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
                BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
                try {
                    p.waitFor();
                } catch (InterruptedException ex) {
                    Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
                }
                String processStr = reader.readLine();
                System.out.println(processStr);
                //writer.write("ls");
                //writer.newLine();
                int j=0;
                String temp="";
                
                while (processStr!= null) {
                    //System.out.println("w1");
                    System.out.println(processStr+"x");
                    //model.setValueAt(line, i, 0);
                    if(!processStr.startsWith("Status")){
                        //processStr.split(line);
                        int k=0;
                        while(processStr.charAt(k)==' '){
                            k++;
                            System.out.println(k+"char"+temp);
                        }
                        System.out.println(k);
                        temp+=processStr.charAt(k);
                        temp+=" ";
                        k++;
                        
                        while(processStr.charAt(k)==' '){
                            k++;
                            System.out.println(k+"rev"+temp);
                        }
                        temp+=processStr.charAt(k);
                        k++;
                        while(processStr.charAt(k)!=' '){
                            temp+=processStr.charAt(k);
                            System.out.println(k+"se"+temp);
                            k++;
                        }
                        System.out.println(k+"se"+temp);
                        temp+=" / ";
                        //return temp;
                        //model.setValueAt(temp, i, model.getColumnCount()-1);
                    }
                    if(processStr.startsWith("Status")){
                        int m=processStr.length()-1;
                        String temp2="";
                        while(processStr.charAt(m)!=' '){
                            temp2=processStr.charAt(m) +temp2;
                            m--;
                        }
                        temp=temp+temp2;
                    }
                    //temp=temp+temp2;
                    envModel.setValueAt(temp, i, envModel.getColumnCount()-1);

                    if (reader.ready()) {
                        //System.out.println("ready");
                        processStr = reader.readLine();
                    } else {
                        processStr = null;
                    }
                }

                p.destroy();
            } catch (IOException ex) {
                Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        

    }
    
    
    
    
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(VHDLview.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(VHDLview.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(VHDLview.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(VHDLview.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                try {
                    new VHDLview().setVisible(true);
                } catch (TooManyListenersException ex) {
                    Logger.getLogger(VHDLview.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton autoEnv;
    private javax.swing.JButton autoFillTB;
    private javax.swing.JButton auto_populate_button;
    private javax.swing.JButton cdcButton;
    private javax.swing.JTabbedPane designPane;
    private javax.swing.JButton dsnCompileButton;
    private javax.swing.JButton dupButton;
    private javax.swing.JTable envTable;
    private javax.swing.JLabel head_rev_label;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JList logFileList;
    private javax.swing.JTextField logSearchText;
    private javax.swing.JTextArea logText;
    private javax.swing.JPasswordField passwordField;
    private javax.swing.JButton runAllButton;
    private javax.swing.JButton runButton;
    private javax.swing.JButton searchButton;
    private javax.swing.JButton spyglassButton;
    private javax.swing.JTable tbTable;
    private javax.swing.JButton updateRevButton;
    private javax.swing.JTextField usernameField;
    // End of variables declaration//GEN-END:variables
}
